﻿@model TechnicBlog.Models.ClassesEntity
@{
    Layout = null;
}
<script type="text/javascript">
    $(function () {
        $("#rptList").datagrid({
            url: "Student/List?ClassesId=" + $("#hfClassesId").val() + "&r=" + Math.random(),
            onRowContextMenu: function (e, rowindex, rowData) {
                $("#rptList").datagrid('selectRow', rowindex);
                e.preventDefault();
                var row = $("#rptList").datagrid('getSelected');
                if (row) {
                    $('#menuStudent').menu('show', {
                        left: e.pageX,
                        top: e.pageY
                    });
                }
            }

        });
    });
    function Delete() {
        var row = $("#rptList").datagrid('getSelected');
        if (row) {
            $.messager.confirm('提醒', '<br>确定要删除' + row.S_Name + '这个学生吗?', function (r) {
                if (r) {
                    form1.action = "Student/Delete/?S_Id=" + row.S_Id;
                    //alert(form1.action+"   "+this.action);
                    $('#loading').window('open');
                    $("#form1").ajaxSubmit({ action: this.action, method: this.method });
                }
            });
        } else {
            $.messager.alert('错误', '<br>请先选择要删除的数据！', 'error');
        }
    }
    function Edit() {
        var row = $("#rptList").datagrid('getSelected');
        if (row) {
            TreeLink('Student/Edit/' + row.S_Id, '用户编辑');
        } else {
            $.messager.alert('错误', '<br>请先选择要编辑的数据！', 'error');
        }
    }
    function Score() {
        var row = $("#rptList").datagrid('getSelected');
        if (row) {
            TreeLink('Score/Index/' + row.S_Id, '成绩管理');
        } else {
            $.messager.alert('错误', '<br>请先选择要一个学生！', 'error');
        }
    }
    function RequestError() {
        $.messager.alert('错误', '<br>请求失败！', 'error');
    }
    function Search() {
        $("#rptList").datagrid({
            url: "Student/List?ClassesId=" + $("#hfClassesId").val() + "&S_Name=" + escape($.trim($("#S_Name").val())) + "&r=" + Math.random(),
            pageNumber: 1
        }).datagrid('reload');
    }
    function formatSex(val, row) {
        if (val == "1") {
            return "男";
        }
        else {
            return "女";
        }
    }
    function formatGrades(val, row) {
        return row.S_Classes + "(" + val + ")班"
    }
</script>
<form id="form1" action="Student/Delete" method="post" data-ajax-failure="RequestError"
data-ajax="true">
@Html.HiddenFor(model=>model.Id,new {id="hfClassesId"})
<div style="padding: 10px;">
    <table id="rptList" class="easyui-datagrid" width="100%" cache="false" title="Load Data"
        singleselect="true" toolbar="#tb" iconcls="icon-save" rownumbers="true" pagination="true"
        pagelist="[10,20,25,30]">
        <thead>
            <tr>
                <th field="S_Id" width="50" align="center" hidden="true">
                    S_Id
                </th>
                <th field="S_Name" width="100">
                    学生姓名
                </th>
                <th field="S_Sex" width="40" align="center" formatter="formatSex">
                    性别
                </th>
                <th field="S_Birthday" width="100" align="center">
                    出生年月
                </th>
                <th field="S_Mobile" width="100">
                    联系电话
                </th>
                <th field="S_Address" width="250">
                    联系地址
                </th>
            </tr>
        </thead>
    </table>
</div>
<div id="tb" style="height: auto">
    <div style="padding: 5px; height: 26px;">
        <a href="javascript:TreeLink('Student/Create/'+$('#hfClassesId').val(),'新增学生基本信息')" class="easyui-linkbutton"
            style="float: left;" iconcls="icon-add" plain="true">新增</a>
        <div class="dialog-tool-separator">
        </div>
        <a href="javascript:void(0)" onclick="Edit();" class="easyui-linkbutton" style="float: left;"
            iconcls="icon-edit" plain="true">编辑</a>
        <div class="dialog-tool-separator">
        </div>
        <a href="javascript:void(0);" class="easyui-linkbutton" style="float: left;" iconcls="icon-cut"
            plain="true" onclick="javascript:Delete();">删除</a>
        <div class="dialog-tool-separator">
        </div>
        <a href="javascript:void(0);" class="easyui-linkbutton" style="float: left;" iconcls="icon-save"
            plain="true" onclick="javascript:Score();">成绩管理</a>
        <div class="dialog-tool-separator">
        </div>
        <a href="javascript:void(0);" class="easyui-linkbutton" style="float: left;" iconcls="icon-search"
            plain="true" onclick="javascript:Search();">查找</a>
        <div class="dialog-tool-separator">
        </div>
        <a href="javascript:void(0);" class="easyui-linkbutton" style="float: left;" iconcls="icon-back"
            plain="true" onclick="javascript:TreeLink('Classes/Index', '班级管理');">返回</a>
    </div>
    <div style="border-top: 1px solid #CCCCCC; padding: 5px;">
        班级:<span id="spClasses" style="color:Red;">@Html.DisplayFor(model=>model.ClassName)</span>&nbsp;&nbsp;&nbsp;&nbsp;
        学生姓名:
        <input id="S_Name" />
        <a href="javascript:Search();" class="easyui-linkbutton" iconcls="icon-search">Search</a>
    </div>
</div>
<div id="menuStudent" class="easyui-menu" style="width: 120px;">
    <div iconcls="icon-edit" onclick="javascript:Edit();">
        编辑</div>
    <div class="menu-sep">
    </div>
    <div iconcls="icon-remove" onclick="javascript:Delete()">
        删除</div>
    <div class="menu-sep">
    </div>
    <div iconcls="icon-save" onclick="javascript:Score()">
        成绩管理</div>
</div>
</form>
